﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProjectWebNhac.BUS;
using System.Data;

namespace ProjectWebNhac.GUI.User
{
    public partial class UserChiTiet : System.Web.UI.MasterPage
    {
        CaSiBus csbus = new CaSiBus();
        BaiHatBus bhbus = new BaiHatBus();
        VideoBus videoBus = new VideoBus();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadBXHVideo();
                loadBXHTop10();
            }
        }

        private void loadBXHTop10()
        {
            reBXHNhac.DataSource = bhbus.User_LoadBXHTop10();
            reBXHNhac.DataBind();
        }

        private void LoadBXHVideo()
        {
            reBXHVideo.DataSource = videoBus.LayTop20VideoHaynhat();
            reBXHVideo.DataBind();
        }

        protected void reBaiHat_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;
            int MaBaiHat;
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView usrCurrent = e.Item.DataItem as DataRowView;
                MaBaiHat = Convert.ToInt16(usrCurrent["MaBaiHat"]);
                Repeater reDSCaSiBaiHat = (Repeater)e.Item.FindControl("reDSCaSiBaiHat");
                reDSCaSiBaiHat.DataSource = csbus.LayCaSiTheoBaiHatTable(MaBaiHat);
                reDSCaSiBaiHat.DataBind();
            }
        }

        protected void reBXHVideo_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;
            int MaVideo;
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView usrCurrent = e.Item.DataItem as DataRowView;
                MaVideo = Convert.ToInt16(usrCurrent["MaVideo"]);
                Repeater reCaSiBXHVideo = (Repeater)e.Item.FindControl("reCaSiBXHVideo");
                reCaSiBXHVideo.DataSource = videoBus.LayChiTietVideo(MaVideo);
                reCaSiBXHVideo.DataBind();
            }
        }

        protected void lnkNgheHetBXH_Click(object sender, EventArgs e)
        {
            Response.Redirect("ChiTietAlbum.aspx?MaBXH=4");
        }
    }
}